package com.iyundao.io.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;
import com.iyundao.io.model.UserRole;
import org.springframework.stereotype.Repository;


@Repository
public class UserRoleSqlProvider {

    public String insertSelective(UserRole record) {
        BEGIN();
        INSERT_INTO("user_role");
        
        if (record.getSid() != null) {
            VALUES("sid", "#{sid,jdbcType=CHAR}");
        }
        
        if (record.getUid() != null) {
            VALUES("uid", "#{uid,jdbcType=CHAR}");
        }
        
        if (record.getRid() != null) {
            VALUES("rid", "#{rid,jdbcType=CHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(UserRole record) {
        BEGIN();
        UPDATE("user_role");
        
        if (record.getUid() != null) {
            SET("uid = #{uid,jdbcType=CHAR}");
        }
        
        if (record.getRid() != null) {
            SET("rid = #{rid,jdbcType=CHAR}");
        }
        
        WHERE("sid = #{sid,jdbcType=CHAR}");
        
        return SQL();
    }
}